package com.example.interview.no0103.solution;

import com.example.interview.no0103.Solution;

/**
 * @Description 解答-URL化
 * @ClassName ArraySolution
 * @Author Administrator
 * @Date 2020/7/7 19:36
 * @Version 1.0.0
 */
public class StringBuilderSolution implements Solution {

    @Override
    public String replaceSpaces(String s, int length) {

        StringBuilder sb = new StringBuilder();

        for(int i = 0; i < length; i++){
            if(s.charAt(i) == ' ') {
                sb.append("%20");
            } else {
                sb.append(s.charAt(i));
            }
        }
        return sb.toString();
    }
}
